#!/bin/bash
#功能：导出所有车的0200部分数据

CUR_DIR=$(cd "$(dirname "$0")"; pwd)

if [ $# -ge 1 ]; then
    echo "Shell 传递参数$#个！"
        echo "执行的文件名：$0"
        echo "第一个参数为：$1"

else
    echo "参数错误！"
    echo "Shell 传递参数$#个！"
    echo "第一个参数为：生成文件的地址"
    exit 1
fi

#步骤一参数准备

target_dir=$1

if [ ! -d $target_dir ];then
   echo "路径不存在,创建路径"
   mkdir -p $target_dir
fi

hive -e "select T_COMMUNICATION_ID from dataplatform_huashen.ods_hy_car_terminal_temp where T_COMMUNICATION_ID is not null;" > ${target_dir}/tids.txt

if [ ! -d $target_dir/log ];then
   echo "log路径不存在,创建路径"
   mkdir -p $target_dir/log
fi

logdir=$target_dir/log

cat ${target_dir}/tids.txt | while read tid
do
  . $CUR_DIR/export_0200_data_single.sh $tid ${target_dir} > /$logdir/export_0200_data_single_$tid.log 2>&1
done
